package com.itheima.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.mapper.OrdersMapper;
import com.itheima.pojo.Orders;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * @author 林晓伟
 */
@Service
public class OrdersService {
    @Resource
    private OrdersMapper ordersMapper;

    /**
     * H23-订单分页查询
     * @param beginTime 开始时间
     * @param endTime 结束时间
     * @param number id
     * @param page 页数
     * @param pageSize 每页条数
     */
    public Page<Orders> select(Integer page, Integer pageSize,String beginTime,String endTime,String number) {
        LambdaQueryWrapper<Orders> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        lambdaQueryWrapper.ge(beginTime !=null,Orders::getOrderTime, beginTime)
                .le(endTime !=null,Orders::getOrderTime, endTime)
                .eq(number!=null,Orders::getNumber,number);

        Page<Orders> page1 = new Page<>(page,pageSize);
        return ordersMapper.selectPage(page1,lambdaQueryWrapper);
    }

    /**
     * H24-修改订单状态
     */
    public Integer jk(Orders orders){
        return ordersMapper.jk(orders);
    }

}
